/*SPI routines*/
#ifndef AUDIOFILE_H
#define AUDIOFILE_H

#include "FreeRTOS.h"

/*Configurations*/

/*Definitions*/	

/*enumerations*/

/*Types Definition, unions*/
#pragma anon_unions

typedef struct 
{

  portLONG     lRIFF;         //RIFF header   "RIFF" 
  portLONG     lFileSize;     //FileSize - 8
  portLONG     lFormat;       //Format header "WAVE"
  portLONG     lSubChunkID;   //("fmt ")
  portLONG     lSubChunkSize; //
  portSHORT    sAudioFmt;     //1-wav other means sort of compression
  portSHORT    sChannels;     //channels 1 = mono; 2 = stereo
  portLONG     lFrequency;    //sample frequency
  portLONG     lByteRate;     //Byte Rate
  portSHORT    sBlockAlign;   //Block Align
  portSHORT    cBitRes;       //bit resolution 8/16 bit      
  portLONG     lDATA;         //Format header "data"
  portLONG     lSubchunk2Size;//NumSamples * NumChannels * BitsPerSample/8
} tAfFormatChunk, *pAfFormatChunk;

/*Constants*/

/*Variable Definition*/

/*Functionality enabling*/

/*Public Functions and procedures Declaration*/

/*Macro definitions*/
#define CHUNK_WAV_GET_CHANNELS(x)   ((pAfFormatChunk)  x)->sChannels
#define CHUNK_WAV_GET_BITRES(x)     ((pAfFormatChunk)  x)->cBitRes
#define CHUNK_WAV_GET_FREQUENCY(x)  ((pAfFormatChunk)  x)->lFrequency
#define CHUNK_WAV_GET_BLOCKALIGN(x) ((pAfFormatChunk)  x)->sBlockAlign
#define CHUNK_WAV_GET_FILESIZE(x)   (((pAfFormatChunk) x)->lFileSize + 8)
#define CHUNK_WAV_IS_RIFF(x)        (((pAfFormatChunk) x)->lRIFF   == 0x46464952)
#define CHUNK_WAV_IS_WAVE(x)        (((pAfFormatChunk) x)->lFormat == 0x45564157)
#define CHUNK_WAV_HAS_data(x)       (((pAfFormatChunk) x)->lDATA   == 0x61746164)
                               
#endif //AUDIOFILE_H
